package com.gel.shortLink.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gel.shortLink.convention.result.Result;
import com.gel.shortLink.convention.result.Results;
import com.gel.shortLink.dto.req.ShortLinkGroupStatsAccessRecordReqDTO;
import com.gel.shortLink.dto.req.ShortLinkGroupStatsReqDTO;
import com.gel.shortLink.dto.req.ShortLinkStatsAccessRecordReqDTO;
import com.gel.shortLink.dto.req.ShortLinkStatsReqDTO;
import com.gel.shortLink.dto.resp.ShortLinkStatsAccessRecordRespDTO;
import com.gel.shortLink.dto.resp.ShortLinkStatsRespDTO;
import com.gel.shortLink.service.LinkStatsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/*短链接监控控制层*/
@RestController
//@RequestMapping("/api/short-link/project/stats")
@RequiredArgsConstructor
public class LinkStatsController {
    private final LinkStatsService linkStatsService;
    /*访问单个短链接指定时间内监控数据*/
    @GetMapping("/api/short-link/project/stats")
    public Result<ShortLinkStatsRespDTO> shortLinkStats(@RequestBody ShortLinkStatsReqDTO requestParam){
        return Results.success(linkStatsService.oneShortLinkStats(requestParam));
    }
    /*访问分组短链接指定时间内监控数据*/
    @GetMapping("/api/short-link/project/stats/group")
    public Result<ShortLinkStatsRespDTO> groupShortLinkStats(@RequestBody ShortLinkGroupStatsReqDTO requestParam) {
        return Results.success(linkStatsService.groupShortLinkStats(requestParam));
    }
    /*访问单个短链接指定是按内访问记录监控数据*/
    @GetMapping("/api/short-link/project/stats/access-record")
    public Result<IPage<ShortLinkStatsAccessRecordRespDTO>> shortLinkStatsAccessRecord(@RequestBody ShortLinkStatsAccessRecordReqDTO requestParam) {
        return Results.success(linkStatsService.shortLinkStatsAccessRecord(requestParam));
    }
   /*访问分组短链接指定时间内监控数据*/
   @GetMapping("/api/short-link/project/stats/access-record/group")
   public Result<IPage<ShortLinkStatsAccessRecordRespDTO>> groupShortLinkStatsAccessRecord(@RequestBody ShortLinkGroupStatsAccessRecordReqDTO requestParam) {
       return Results.success(linkStatsService.groupShortLinkStatsAccessRecord(requestParam));
   }

}
